Interactive Data Visualization with Plotly

Lukhanyiso Bvuma

2025-10-01

Welcome to Interactive Visualizations!

Date Created: October 01, 2025

This presentation showcases the power of Plotly for creating interactive, web-based visualizations in R.

What makes Plotly special?

Dataset: mtcars

We’ll explore the classic mtcars dataset with interactive plots.

Sample of mtcars dataset
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2

Variables: - mpg: Miles per gallon - hp: Horsepower
- wt: Weight (1000 lbs) - cyl: Number of cylinders

Interactive Scatter Plot

Try hovering over the points! Notice the relationship between weight and fuel efficiency.

3D Interactive Plot

Try rotating the plot! Click and drag to explore different angles.

Box Plot: Distribution by Cylinders

Insight: Fewer cylinders generally mean better fuel efficiency.

Bar Chart: Average MPG by Cylinder

Correlation Heatmap

Strong negative correlations (blue) between weight/cylinders and fuel efficiency.

Line Chart: Performance Comparison

Animated Bubble Chart

Click play! Watch how cars are distributed across the power spectrum.

Key Takeaways

What we learned:

  1. Weight matters: Heavier cars consume more fuel
  2. Cylinders count: More cylinders = less efficiency
  3. Power trade-off: High horsepower typically means lower MPG
  4. Interactive is better: Plotly makes data exploration intuitive

Why use Plotly?

Resources & Next Steps

Learn More:

Try it yourself:

# Basic example
library(plotly)
plot_ly(data = iris,
        x = ~Sepal.Length,
        y = ~Petal.Length,
        color = ~Species)

Publishing options: - GitHub Pages (free hosting) - RPubs (easy one-click publishing) - NeoCities (simple hosting)

Thank You!

Presentation created on: October 01, 2025

Tools used: - R Markdown - Plotly for R - Slidy presentation format

All plots are interactive - hover, click, zoom, and explore!


Questions or feedback?
[Your Email] | [Your GitHub]